import { watcher } from "@feng3d/watcher";
import { ConeGeometry } from "../../thirdparty/three/imports";
import { BufferGeometry3D } from "../core/BufferGeometry3D";

export class ConeGeometry3D extends BufferGeometry3D
{
    radius?: number;
    height?: number;
    radialSegments?: number;
    heightSegments?: number;
    openEnded?: boolean;
    thetaStart?: number;
    thetaLength?: number;

    get _geometry()
    {
        if (!this.__geometry)
        {
            this.__geometry = new ConeGeometry(this.radius, this.height, this.radialSegments, this.heightSegments, this.openEnded, this.thetaStart, this.thetaLength);
        }

        return this.__geometry;
    }
    declare protected __geometry: ConeGeometry;

    constructor()
    {
        super();

        watcher.watchs(this as ConeGeometry3D, ["radius", "height", "radialSegments", "heightSegments", "openEnded", "thetaStart", "thetaLength"], this._invalidate, this);
    }

    destroy()
    {
        watcher.unwatchs(this as ConeGeometry3D, ["radius", "height", "radialSegments", "heightSegments", "openEnded", "thetaStart", "thetaLength"], this._invalidate, this);
    }
}
